#include <bits/stdc++.h>

using namespace std;

#define fi(i, init, n) for (int i = init; i < n; i++)   // i为循环变量，a为初始值，n为界限值，递增
#define rfi(i, init, n) for (int i = init; i > n; i--)  // i为循环变量， a为初始值，n为界限值，递减。
#define vi vector<int>
#define mii unordered_map<int, int>
#define between(a, l, h) (a >= l && a <= h)
const int INF = 0x7fffffff;  // 无穷大
typedef long long ll;
class Solution {
public:
    vector<int> occurrencesOfElement(vector<int>& nums, vector<int>& queries, int x) {
        vi idxs;
        fi(i, 0, nums.size()) {
            if (nums[i] == x) idxs.push_back(i);
        }
        vi ans;
        for (auto q : queries) {
            if (q > idxs.size())
                ans.push_back(-1);
            else
                ans.push_back(idxs[q - 1]);
        }
        return ans;
    }
};

// int main(int argc, const char** argv) {
//     Solution solution = Solution();
//     vector<int> in = {2, 1, 1};
//     auto res = solution.solution(in);
//     cout << res << endl;
//     return 0;
// }